package com.wyx.Dao;

import com.wyx.Pojo.Book;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
/**
 * 图书的DAO层 与数据库进行连接
 */
@Mapper
public interface BookDao {
    @Select("select * from jd_book where id=#{id}")
    Book selectbyId(Integer id);
    @Select("select * from jd_book")
    List<Book> selectall();
    @Update("update jd_book set type=#{type},writter=#{writter},name=#{name},description=#{description},count=#{count} where id=#{id}")
    Integer update(Book book);
    @Delete("delete from jd_book where id=#{id}")
    Integer delete(Integer id);
    @Insert("insert into jd_book(type,name,writter,description,count)VALUES (#{type},#{name},#{writter},#{description},#{count})")
    Integer add(Book book);
    @Select("select * from jd_book where name like #{name} and writter like #{writter} limit #{page},#{pagesizes}")
    List<Book>getPage(@Param("name") String name, @Param("writter") String writter,@Param("page") Integer page,@Param("pagesizes") Integer pagesizes);
    @Select("SELECT COUNT(*)FROM jd_book where name like #{name} and writter like #{writter}")
    Integer getCount(@Param("name") String name, @Param("writter") String writter);
}
